package com.kl.forum.api;

import com.kl.forum.entity.qo.CircleQo;
import com.kl.forum.service.CircleService;
import com.kl.forum.util.ResultInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@Api("圈子模块")
@RestController
@RequestMapping("/circle")
public class CircleControllerAPI {
    @Autowired
    private CircleService circleService;

    /**
     *精选内容
     * @return
     */
    @ApiOperation(value = "精选内容",notes="圈子 lightStatus userStatus    1关注 0未关注 ")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户ID", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Long")
    })
    @RequestMapping(value = "/findEssenceCircle",method= RequestMethod.GET)
    public ResultInfo findEssenceCircle(@RequestParam(value = "userId",required = false)Integer userId,Integer pageNum,Integer pageSize){
       return circleService.findEssenceCircle(userId,pageNum,pageSize);
    }



    /**
     * 发表帖子
     * @return
     */
    @ApiOperation(value = "发表帖子",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "circleId", value = "圈子Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "content", value = "内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "files", value = "文件List<MultipartFile>", required = false, dataType = "String"),
            @ApiImplicitParam(name = "type", value = "类型 video pic", required = false, dataType = "String"),

    })
    @RequestMapping(value = "/insertCircleArticle",method= RequestMethod.POST)
    public  ResultInfo insertCircleArticle(CircleQo circleQo) throws Exception {
        return circleService.insertCircleArticle(circleQo.getUserId(), circleQo.getCircleId(), circleQo.getContent(),circleQo.getFiles(),circleQo.getType());
    }

    /**
     * 点赞文章
     * @param articleId
     * @param userId
     * @return
     */
    @ApiOperation(value = "点赞文章",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "lightCircleArticle",method = RequestMethod.POST)
    public  ResultInfo lightCircleArticle(Integer articleId,Integer userId){
      return   circleService.lightCircleArticle(articleId,userId);
    }
    /**
     * 取消点赞文章
     * @param articleId
     * @param userId
     * @return
     */
    @ApiOperation(value = "取消点赞文章",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "darkCircleArticle",method = RequestMethod.POST)
    public  ResultInfo darkCircleArticle(Integer articleId,Integer userId){
        return   circleService.darkCircleArticle(articleId,userId);
    }

    /**
     * 收藏文章
     * @param articleId
     * @param userId
     * @return
     */
    @ApiOperation(value = "收藏文章",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "insertCircleCollect",method = RequestMethod.POST)
    public  ResultInfo insertCircleCollect(Integer articleId,Integer userId){
        return   circleService.insertCircleCollect(articleId,userId);
    }

    /**
     * 取消收藏文章
     * @param articleId
     * @param userId
     * @return
     */
    @ApiOperation(value = "取消收藏文章",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "articleId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "updateCircleCollect",method = RequestMethod.POST)
    public  ResultInfo updateCircleCollect(Integer articleId,Integer userId){
        return   circleService.updateCircleCollect(articleId,userId);
    }





    /**
     * 删除帖子 逻辑删除
     * @return
     */
    @ApiOperation(value = "删除帖子",notes="圈子")
    @ApiImplicitParam(name = "circleArticleId", value = "帖子Id", required = true, dataType = "Long")
    @RequestMapping(value = "/delCircleArticle",method= RequestMethod.POST)
    public ResultInfo delCircleArticle(Integer circleArticleId){
        return circleService.delCircleArticle(circleArticleId);
    }

    /**
     * 评论列表
     * @return
     */
    @ApiOperation(value = "评论列表",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "circleArticleId", value = "帖子Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "sort", value = "排序条件 1时间正序 2时间倒叙 3点赞数倒叙", required = true, dataType = "Long")

    })
    @RequestMapping(value = "/findCircleComment",method= RequestMethod.GET)
    public  ResultInfo findCircleComment(@RequestParam(value = "userId",required = false) Integer userId,Integer circleArticleId,Integer pageNum,Integer pageSize,String sort){
        return circleService.findCircleComment(userId,circleArticleId,pageNum,pageSize,sort);

    }


    /**
     * 文章评论回复列表
     * @return
     */
    @ApiOperation(value = "文章评论回复列表(详情) ",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "commentId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageNum", value = "页码", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageSize", value = "每页大小", required = true, dataType = "Long"),

    })
    @RequestMapping(value = "/findArticleCommentReplyList",method= RequestMethod.GET)
    public  ResultInfo findArticleCommentReplyList(@RequestParam(value = "userId" ,required = false) Integer userId,Integer commentId,Integer pageNum ,Integer pageSize){
        return   circleService.findArticleCommentReplyList(userId,commentId,pageNum,pageSize);
    }







    /**
     * 发表评论
     * @param userId
     * @param circleArticleId
     * @param content
     * @return
     */
    @ApiOperation(value = "发表评论",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "circleArticleId", value = "帖子Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "content", value = "内容", required = true, dataType = "String"),
    })
    @RequestMapping(value = "/insertCircleComment",method= RequestMethod.POST)
    public  ResultInfo insertCircleComment(Integer userId,Integer circleArticleId,String content){
        return  circleService.insertCircleComment(userId,circleArticleId,content);
    }

    /**
     * 点赞评论
     * @return
     */
    @ApiOperation(value = "点赞评论",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/lightCircleComment",method= RequestMethod.POST)
    public  ResultInfo lightCircleComment(Integer commentId ,Integer userId){
        return  circleService.lightCircleComment(commentId,userId);

    }


    /**
     * 取消点赞评论
     * @return
     */
    @ApiOperation(value = "取消点赞评论",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/darkCircleComment",method= RequestMethod.POST)
    public  ResultInfo darkCircleComment(Integer commentId ,Integer userId){
        return  circleService.darkCircleComment(commentId,userId);
    }

    /**
     * 删除评论
     * @return
     */
    @ApiOperation(value = "删除评论",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/delCircleComment",method= RequestMethod.POST)
    public  ResultInfo delCircleComment(Integer commentId ){
        return  circleService.delCircleComment(commentId);
    }



    /**
     * 发表回复
     * @return
     */
    @ApiOperation(value = "发表回复",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "commentId", value = "评论Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userName", value = "用户姓名", required = true, dataType = "String"),
            @ApiImplicitParam(name = "content", value = "内容", required = true, dataType = "String"),
            @ApiImplicitParam(name = "articleId", value = "文章Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "commentName", value = "被评论人姓名", required = false, dataType = "String"),
            @ApiImplicitParam(name = "commentNameId", value = "被评论人ID", required = false, dataType = "Long"),

    })
    @RequestMapping(value = "/insertCircleCommentReply",method= RequestMethod.POST)
    public  ResultInfo insertCircleCommentReply(Integer commentId,Integer userId ,String userName,String content,Integer articleId ,@RequestParam(value = "commentName" ,required = false) String commentName,@RequestParam(value = "commentNameId" ,required = false)Integer commentNameId){
        return  circleService.insertCircleCommentReply(commentId,userId,userName,content,articleId,commentName,commentNameId);
    }


    /**
     * 删除回复
     * @param replyId
     * @param
     * @return
     */
    @ApiOperation(value = "删除回复",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "replyId", value = "回复Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/findCircleCommentReply",method= RequestMethod.POST)
    public ResultInfo delCircleCommentReply(Integer replyId){
        return circleService.delCircleCommentReply(replyId);
    }

    /**
     * 点赞回复
     * @param
     * @param
     * @return
     */
    @ApiOperation(value = "点赞回复",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "replyId", value = "回复Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/lightCircleCommentReply",method= RequestMethod.POST)
    public ResultInfo lightCircleCommentReply(Integer replyId,Integer userId){
        return circleService.lightCircleCommentReply(replyId,userId);

    }

    /**
     * 点灭回复
     * @param
     * @param
     * @return
     */
    @ApiOperation(value = "点赞回复",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "replyId", value = "回复Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "/darkCircleCommentReply",method= RequestMethod.POST)
    public ResultInfo darkCircleCommentReply(Integer replyId,Integer userId){
        return circleService.darkCircleCommentReply(replyId,userId);

    }


    /**
     * 所有圈子
     * @return
     */
    @ApiOperation(value = "所有圈子",notes="圈子")
    @RequestMapping(value = "findCircle",method = RequestMethod.GET)
    public ResultInfo findCircle(){
        return circleService.findCircle();
    }

    /**
     * 圈子详情
     * @param circleId
     * @return
     */
    @ApiOperation(value = "圈子详情",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "circleId", value = "圈子Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
    })
    @RequestMapping(value = "findCircleOne",method = RequestMethod.GET)
    public ResultInfo findCircleOne(Integer circleId, @RequestParam(value = "userId",required = false)Integer userId){
        return circleService.findCircleOne(circleId,userId);
    }
    /**
     * 置顶帖子
     * @param circleId
     * @return
     */
    @ApiOperation(value = "置顶帖子",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "circleId", value = "圈子Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
    })
    @RequestMapping(value = "findCircleArticleTop",method = RequestMethod.GET)
    public  ResultInfo findCircleArticleTop(Integer circleId){
        return circleService.findCircleArticleTop(circleId);
    }


    /**
     * 帖子列表
     * @param circleId
     * @return
     */
    @ApiOperation(value = "帖子列表",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "circleId", value = "圈子Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "sort", value = "1-所有 2-精华 3-回复时间 ", required = true, dataType = "String")

    })
    @RequestMapping(value = "findCircleArticleBySort",method = RequestMethod.GET)
    public  ResultInfo findCircleArticleBySort(@RequestParam(value = "userId",required = false)Integer userId,@RequestParam(value = "circleId",required = false)Integer circleId,Integer pageNum,Integer pageSize,String sort){
        return circleService.findCircleArticleBySort(userId,circleId,pageNum,pageSize,sort);

    }


    /**
     * 更多关注 推荐的用户
     * @return
     */
    @ApiOperation(value = "更多关注 推荐更多的用户",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
    })
    @RequestMapping(value = "findUserByRecommend",method = RequestMethod.GET)
    public  ResultInfo findUserByRecommend(@RequestParam(value = "userId",required = false) Integer userId){
        return circleService.findUserByRecommend(userId);
    }

//    /**
//     * 我的点赞
//     * @param userId
//     * @return
//     */
//    @ApiOperation(value = "我的 点赞",notes="圈子")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
//            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "Long"),
//            @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Long")
//    })
//    @RequestMapping(value = "findMyLight",method = RequestMethod.GET)
//    public ResultInfo findMyLight(Integer userId,Integer pageNum,Integer pageSize){
//        return circleService.findMyLight(userId,pageNum,pageSize);
//    }
//
//
//    /**
//     * 我的评论
//     * @param userId
//     * @return
//     */
//    @ApiOperation(value = "我的评论",notes="圈子")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
//            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "Long"),
//            @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Long")
//    })
//    @RequestMapping(value = "findMyComment",method = RequestMethod.GET)
//    public ResultInfo findMyComment(Integer userId,Integer pageNum,Integer pageSize){
//        return circleService.findMyComment(userId,pageNum,pageSize);
//    }


    /**
     * 帖子详情
     * @param
     * @return
     */
    @ApiOperation(value = "帖子详情",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "id", value = "id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "findCircleArticleDetail",method = RequestMethod.GET)
    public  ResultInfo  findCircleArticleDetail(Integer userId,Integer id){
        return circleService.findCircleArticleDetail(userId,id);

    }

    /**
     * 关注圈子
     * @param
     * @return
     */
    @ApiOperation(value = "关注圈子",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "circleId", value = "圈子id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "insertUserCircle",method = RequestMethod.POST)
    public  ResultInfo  insertUserCircle(Integer userId,Integer circleId){
        return circleService.insertUserCircle(userId,circleId);

    }

    /**
     * 取消关注圈子
     * @param
     * @return
     */
    @ApiOperation(value = "取消关注圈子",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "circleId", value = "圈子id", required = true, dataType = "Long")
    })
    @RequestMapping(value = "updateUserCircle",method = RequestMethod.POST)
    public  ResultInfo  updateUserCircle(Integer userId,Integer circleId){
        return circleService.updateUserCircle(userId,circleId);

    }


    /**
     * 我关注的圈子
     * @param
     * @return
     */
    @ApiOperation(value = "我关注的圈子",notes="圈子")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageNum", value = "页数", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "pageSize", value = "页码大小", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "findMyCircle",method = RequestMethod.GET)
    public  ResultInfo  findMyCircle(Integer userId ,Integer pageNum,Integer pageSize){
        return circleService.findMyCircle(userId,pageNum,pageSize);

    }

    /**
     * 举报用户和帖子
     * @param
     * @return
     */
    @ApiOperation(value = "举报用户和帖子",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "accusedUserId", value = "被举报人Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "reportType", value = "类型 1用户 2帖子", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "articleId", value = "帖子Id", required = false, dataType = "Long"),
            @ApiImplicitParam(name = "content", value = "内容", required = false, dataType = "String"),


    })
    @RequestMapping(value = "report",method = RequestMethod.POST)
    public  ResultInfo  report(Integer userId ,Integer accusedUserId,Integer reportType,@RequestParam(value ="articleId" ,required = false) Integer  articleId,@RequestParam(value = "content",required = false) String content){
        return circleService.report(userId,accusedUserId,reportType,articleId,content);

    }


    /**
     * 关注
     * @param
     * @return
     */
    @ApiOperation(value = "去关注用户",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "coverUserId", value = "圈子id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "insertCoverUser",method = RequestMethod.POST)
    public  ResultInfo  insertCoverUser(Integer userId ,Integer coverUserId){
        return circleService.insertCoverUser(userId,coverUserId);

    }


    /**
     * 取消关注
     * @param
     * @return
     */
    @ApiOperation(value = "取消关注",notes="")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "userId", value = "用户Id", required = true, dataType = "Long"),
            @ApiImplicitParam(name = "coverUserId", value = "圈子id", required = true, dataType = "Long"),
    })
    @RequestMapping(value = "updateCoverUser",method = RequestMethod.POST)
    public  ResultInfo  updateCoverUser(Integer userId ,Integer coverUserId){
        return circleService.updateCoverUser(userId,coverUserId);

    }








}
